<?php

namespace App\Http\Controllers\Seller;

use App\Library\Mall\Shop\AuthManagers;
use Illuminate\Http\Request;

class AuthController extends BaseController
{
    use AuthManagers;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->assign(['sideMenu'=>'auth']);
    }

    public function index()
    {
        $shop = $this->user()->shop;
        if ($shop)
        {
            $auth = $this->user()->shop->auth()->firstOrCreate([]);

            if ($auth->auth_state)
            {
                return $this->view('seller.auth.authed', compact('auth'));
            } else {
                return $this->view('seller.auth.auth', compact('auth'));
            }
        }
        return redirect('seller/shop');
    }
}
